<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../../include/admincontent.jsp" %>
<div id="location">当前位置：首页 > 笔试管理 > 考试管理</div>
<div id="Content">
<%--    <div class="btnbar">
        <button type="button" class="add" id="bsexamadd">添加</button>
        <button type="button" class="edit" id="bsexamedit">修改</button>
        <button type="button" class="del" id="bsexamdel">删除</button>
    </div>--%>
    <div class="toolbars" style="height:30px;white-space:nowrap;width:auto;margin-left: 20px;" totalwidth="314">
        <a id="bsexamadd">
            <em id="add_em" class="ico16 add_new"></em>
            <span id="send_span" class="menu_span" title="添加">添加</span>
        </a>
        <a id="bsexamedit">
            <em class="ico16 editor_16"></em>
            <span class="menu_span" title="修改">修改</span>
        </a>
        <a id="bsexamdel">
            <em class="ico16 del_16"></em>
            <span class="menu_span" title="删除">删除</span>
        </a>
    </div>
    <!-- 筛选条件 -->
    <div id="searchbox" style="margin-top: 10px">
        <form id="sform">
            <table class="treeTable searchform">
                <thead>
                <tr>
                    <td width="120">选择考场：</td>
                    <td width="250">
                        <div><select name="roomid">
                            <option value="">全部考场</option>
                            ${room}</select></div>
                    </td>
                    <td width="120">考试名称：</td>
                    <td width="150">
                        <div><input type="text" name="name"/></div>
                    </td>
                    <td width="120">
                        <div class="toolbars">
                            <a id="searchbtn" >
                                <em class="ico16 search_16"></em>
                                <span class="menu_span" title="查询">查询</span>
                            </a>
                        </div>
                    </td>
                    <td></td>
                </tr>
                </thead>
            </table>
        </form>
    </div>
    <table class="treeTable" id="tablelist" lay-filter="examTable">
<%--        <thead>
        <tr>
            <td width="20"><input type="checkbox" class="allcheckbox" title="选择全部/取消全选"/></td>
            <td width="30">序号</td>
            <td width="300">考试名称</td>
            <td width="150">考场名称</td>
            <td width="100">座位数量</td>
            <td width="150">考试起始时间</td>
            <td>考试结束时间</td>
        </tr>
        </thead>
        <tbody id="result"></tbody>--%>
    </table>
<%--    <div id="page"></div>--%>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        /*  getList();
  /*    $('#searchbtn').click(function () {
           getList();
       });*/

        $("#searchbtn").on('click', function () {

                function fun1() {
                    layui.use('table', () => {
                            tavkeIns.reload({
                                url: "/Do/BS/getexamsLayuiJson",
                                where: {
                                    name: $("input[name = 'name']").val(),
                                    roomid: $("select[name = 'roomid']").val(),
                                },
                                page: {
                                    curr: 1
                                }
                            });
                        }
                    );
                }

                fun1.call(layuithis)
            }
        );

        //添加考试
        $('#bsexamadd').click(function () {
            openLayer('添加考试', '/Do/BS/addexam', '80%', '90%');
        });

        //修改考试
        $('#bsexamedit').click(function () {
            //EditInfo('修改考试', '/Do/BS/editexam?_x=2015', '80%', '90%');
            var url = '/Do/BS/editexam?_x=2015';

            var id = '';
            var checkRows = layui.table.checkStatus('examTable').data;
            var count = checkRows.length;

            if (count < 1) {
                layer.msg('请选择一条信息',{icon:7,time:2000});
            } else if (count > 1) {
                layer.msg('只能选择一条信息',{icon:7,time:2000});
            } else {
                $(checkRows).each(function (index, itme) {
                    id = itme.ids.replace('cb_', '');
                });
                openLayer('修改考官信息', url + '&id=' + id, '80%', '98%');
            }
        });

        //删除考试
        $('#bsexamdel').click(function () {
            layer.confirm('删除以后不能恢复，确定要删除吗？', {
                btn: ['是', '否']
            }, function () {
                var checkRows = layui.table.checkStatus('examTable').data;
                var id = '';
                var count = checkRows.length;

                if (count < 1) {
                    layer.msg('请选择一条信息',{icon:7,time:2000});
                } else if (count > 1) {
                    layer.msg('只能选择一条信息',{icon:7,time:2000});
                } else {
                    $(checkRows).each(function (index, itme) {
                        id = itme.ids.replace('cb_', '');
                    });
                    $.post("/Do/BS/DelExamAction", {id: id}, function (result) {
                        if (result.state) {
                            layer.alert(result.Message, {icon: 1});
                            tavkeIns.reload('examTable', {
                                page: {
                                    curr: 1
                                }
                            });
                        } else {
                            layer.alert(result.Message, {icon: 2});
                        }
                    }, "JSON");
                }
                //DelInfo('/Do/BS/DelExamAction');
                //layer.closeAll();
            }, function () {
                //layer.closeAll();
            });
        });

        var tavkeIns;
        let layuithis;
        layui.use('table',function () {
            var table = layui.table;
            layuithis = this;

            tavkeIns = table.render({
                id:'examTable',
                elem:'#tablelist',
                url:'/Do/BS/getexamsLayuiJson',
                height:'full',
                cols:[[
                    {type:'checkbox',fixed:'left'},
                    {field:'id',title:'序号',fixed:'left',sort:true,width:80},
                    {field: 'name',title: '考试名称',fixed: 'left',sort: true,width: 360},
                    {field: 'addname',title: '考场名称',fixed: 'left',sort: true},
                    {field: 'startnum',title: '座位数量',fixed: 'left',sort: true,width:120},
                    {field: 'starttime',title: '考试起始时间',fixed: 'left',sort: true,width: 180},
                    {field: 'endtime',title: '考试结束时间',fixed: 'left',sort: true,width:180},
                ]],
                page:true
            });
        });
    });

    function getList() {
        $('#page').myPagination({
            cssStyle: "pagination",
            ajax: {
                on: true,
                url: '/Do/BS/getexams',
                param: $('#sform').serialize(),
                dataType: 'html',
                callback: function (data) {
                    $('#result').html(data);
                }
            }
        });
    }

</script>
</body>
</html>